package com.hxx.service.impl;

import com.github.pagehelper.PageHelper;
import com.hxx.dao.UserMapper;
import com.hxx.pojo.SysUser;
import com.hxx.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl implements ISysUserService {
    @Autowired
    private UserMapper userMapper;
    /**
     * 根据用户名获取
     * @param sysUser
     * @return
     */
    @Override
    public SysUser getUserByUsernameAndPwd(SysUser sysUser) {
        SysUser user = userMapper.getUserByUsernameAndPwd(sysUser);
        return user;
    }

    @Override
    public List<SysUser> getAllUsers(String username ,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysUser> allUsers = userMapper.getAllUsers(username);
        return allUsers;
    }

    /**
     * 估计ID查询
     * @param id
     * @return
     */
    @Override
    public SysUser getUserById(Integer id) {
        SysUser user = userMapper.getUserById(id);
        return user;
    }
    /**
     * 添加用户
     * @param
     * @return
     */
    @Override
    public int addUser(SysUser sysUser) {
        int i = userMapper.addUser(sysUser);
        return i;
    }
    /**
     * 用户修改
     * @param
     * @return
     */
    @Override
    public int editUser(SysUser sysUser) {
        int i = userMapper.editUser(sysUser);
        return i;
    }
    /**
     * 根据ID删除
     * @param
     * @return
     */
    @Override
    public int deleteUserById(Integer id) {
        int i = userMapper.deleteUserById(id);
        return i;
    }
    /**
     * 根据ID批量删除
     * @param
     * @return
     */
    @Override
    public int deleteUserAll(List<String> ids) {
        int i = userMapper.deleteUserAll(ids);
        return i;
    }

    @Override
    public SysUser getUserByUsername(String username) {
        SysUser user = userMapper.getUserByUsername(username);
        return user;
    }
}
